const App = {
    mixins: [Query],//配置文件，路径/utils/mixins.js
    data() {
        return {
            photo,
            page: {
                value1:'',
                value2:'',
                PageNumber: 1, //页码
                RowAmount: 10,
                // Condition:''
                Condition: window.btoa(unescape(encodeURIComponent("%%,%%"))),
                // ExtensionCondition: window.btoa(unescape(encodeURIComponent(" and  natural_resources_management.Village_SerialNumber in (" + getCookie('village') + ")"))),
            },
        }
    },
    mounted() {
        
    },
    methods: {
        Treedata(){
            $.ajax({
                headers: requestHeaders(),
                url: `${mh}/generalBusiness/getSubsidyTree`,
                type: "GET",
                data:{
                    SubsidyType:'0'
                },
                success: (data) => {
                    data.forEach(item => {
                        item.Policy_SerialNumber = item.Year;
                        item.Policy_Name = item.Year;
                    });
                    this.treeData = data; // 直接使用 this
                },
                complete: (XMLHttpRequest) => {
                    requestPretreatment(XMLHttpRequest);
                },
                dataType: "json",
            });
            // $.ajax({
            //     url: `${mh}/generalBusiness/generalQueryByTableName`,
            //     type: "POST",
            //     data: {
            //         Data: 'subsidy_policy',
            //         Condition: "Row_Status='0'",
            //     },
            //     success: (data) => {
            //         this.treeData = data; // 直接使用 this
            //     },
            //     dataType: "json",
            // });
        },
        check(){
            this.page.Condition = window.btoa(unescape(encodeURIComponent("%" + this.page.value1 + "%,%"+this.page.value2+"%")));
            this.postgetList(this.page);
        },
        //树的点击筛选事件
        handleNodeClick(data, node) {
            if (node.level==2) {
                this.page.Condition = window.btoa(unescape(encodeURIComponent("%" + data.Policy_SerialNumber + "%,%"+this.page.value2+"%")));
                
            } else if (node.level==1){
                this.page.Condition = window.btoa(unescape(encodeURIComponent("%%,%"+this.page.value2+"%")));
                //  and  natural_resources_management.Village_SerialNumber in (" + getCookie('village') + ") 
                this.page.ExtensionCondition = window.btoa(unescape(encodeURIComponent("AND YEAR(subsidy_policy.Expiry_Date) = '"+data.Policy_SerialNumber+"'")));
            }
            this.postgetList(this.page);
        },
        handleEdit(row){
            let { primary_key } = JSON.parse(document.getElementById("table").getAttribute("data-options"));
            window.location.href = "./add1.html?action=Add&nodeKey=" + row[primary_key]+ "&Subsidy_Amount=" + (row.Subsidy_Amount * row.Area) + "&Subsidy_Amount1=" + row.Subsidy_Amount1;;
        },
        handleShow(row){
            window.location.href = "./show.html?action=Modify&nodeKey=" + row.Application_SerialNumber;
        }
    },
};

const { createApp } = Vue;
const app = createApp(App);
//这种方式是引入全部图标，无需单个引入
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component);
}
const ElMessage = ElementPlus.ElMessage;
app.use(ElementPlus,{locale: zhCn});
app.mount("#app");
